// 营销模块的请求
import request from "../request"
import qs from "qs"

// 根据活动名称分页查询接口
export const queryActivityNameApi = (params: IUserListParams): RSP<IUserListData<IActivityRList>> => request.get("/flash/list", { params })

// 删除活动接口 
export const removeActivityNameApi = (id: number): RSP<any> => request.post(`/flash/delete/${id}`)

// 添加活动接口
export const ActivityAddApi = (params: IAddActivity): RSP<any> => request.post("/flash/create", params)

// 编辑活动
export const ActivityEditApi = (params: IAddActivity): RSP<any> => request.post(`/flash/update/${params.id}`, params)

// 获取活动详情
export const getActivityApi = (id: number): RSP<any> => request.get(`/flash/${id}`)

// 修改上下线状态
export const updateStatusApi = (params: IUpdateStatus): RSP<any> => request.post(`/flash/update/status/${params.id}?status=${params.status}`)

// 获取秒杀时间段列表全部场次 
export const getFlashSessionListApi = (): RSP<IFlashSessionLis[]> => request.get("flashSession/list")

// 删除场次请求
export const removeFlashSessionApi = (id: number): RSP<any> => request.post(`/flashSession/delete/${id}`)

// 修改场次启用状态
export const updateFlashSessionStatusApi = (params: IUpdateStatus): RSP<any> => request.post(`/flashSession/update/status/${params.id}?status=${params.status}`)

// 获取场次详情请求 
export const getFlashSessionDetailsApi = (id: number): RSP<IFlashSessionLis> => request.get(`/flashSession/${id}`)

// 添加场次
export const addFlashSessionApi = (params: IFlashSessionLis): RSP<any> => request.post("/flashSession/create", params)

// 修改场次
export const editFlashSessionApi = (params: IFlashSessionLis): RSP<any> => request.post(`/flashSession/update/${params.id}`, params)

// 获取全部可选场次及其数量 
export const getAllSelectList = (id: number): RSP<IAllSelectList[]> => request.get(`/flashSession/selectList?flashPromotionId=${id}`)

// 分页查询不同场次关联及商品信息  
export const queryPageFlashList = (params: queryPageFlashList): RSP<IQueryPageFlashRSP<IQueryPageFlashRSPList>> => request.get(`/flashProductRelation/list?pageNum=${params.pageNum}&pageSize=${params.pageSize}&flashPromotionId=${params.flashPromotionId}&flashPromotionSessionId=${params.flashPromotionSessionId}`)

// 删除关联 
export const removefFashProductRelationApi = (id: number): RSP<any> => request.post(`/flashProductRelation/delete/${id}`)

// 查询商品
export const queryProductApi = (params: IQueryProductParams): RSP<IQueryPageFlashRSP<IQueryPageFlashRSPProduct>> => request.get(`/product/list?pageNum=${params.pageNum}&pageSize=${params.pageSize}&keyword=${params.keyword}`)

// 批量选择商品添加关联  
export const addFlashProductRelation = (params: IAddFlashProductRelationParams[]): RSP<any> => request.post("/flashProductRelation/create", params)

// 修改关联信息  
export const editFlashProductRelation = (params: IEditFlashProductRelationParams): RSP<any> => request.post(`/flashProductRelation/update/${params.id}`, params)

// 根据优惠卷名称和类型分页获取优惠卷列表  
export const getCouponListApi = (params: IGetCouponListParams): RSP<IUserListData<ICouponList>> => request.get(`/coupon/list?pageNum=${params.pageNum}&pageSize=${params.pageSize}&name=${params.name}&type=${params.type}`)

// 删除优惠卷
export const removeCouponApi = (id: number): RSP<any> => request.post(`/coupon/delete/${id}`)

// 添加优惠卷
export const addCouponApi = (params: any): RSP<any> => request.post("/coupon/create", params)

// 根据品牌名称分页获取品牌列表
export const getHomeBrandListApi = (params: IBrandListParams): RSP<IUserListData<IGetHomeBrandList>> => request.get(`/home/brand/list?pageNum=${params.pageNum}&pageSize=${params.pageSize}&brandName=${params.brandName}&recommendStatus=${params.recommendStatus}`)

// 批量修改推荐品牌状态  
export const BatchmModifyBrandApi = (params: IBatchmModifyBrand): RSP<any> => request.post(`/home/brand/update/recommendStatus?` + qs.stringify(params, { arrayFormat: "comma" }))

// 批量修改推荐品牌状态
export const BatchRemoveBrandApi = (params: BatchRemoveBrand): RSP<any> => request.post(`/home/brand/delete?` + qs.stringify(params, { arrayFormat: "comma" }))

// 修改推荐品牌排序
export const editBrandSortApi = (params: editBrandSort): RSP<any> => request.post(`/home/brand/update/sort/${params.id}?sort=${params.sort}`)

// 根据品牌名称分页获取品牌列表
export const getNameBrandListApi = (params: IUserListParams): RSP<IUserListData<getNameBrandList>> => request.get(`/brand/list?keyword=${params.keyword}&pageNum=${params.pageNum}&pageSize=${params.pageSize}`)

// 添加首页推荐品牌请求
export const AddHomeBranApi = (params: AddHomeBrand[]): RSP<any> => request.post("/home/brand/create", params)